/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package mnstudent.presentationlayer;

import mnstudent.global.MyTableCellRender;
import mnstudent.global.MyComboBoxEditor;
import mnstudent.global.MyComboBoxRenderer;
import mnstudent.global.DataTable;
import mnstudent.global.Standard;
import mnstudent.businessLayer.KindOfSubjectBLL;
import mnstudent.businessLayer.SubjectBLL;
import mnstudent.datatranferobject.KindOfSubjectDTO;
import mnstudent.datatranferobject.MajorOfSubjectDTO;
import mnstudent.datatranferobject.MajorOfSubjectDetailDTO;
import mnstudent.datatranferobject.OrderSemesterDTO;
import mnstudent.datatranferobject.PrerequisiteSubjectDTO;
import mnstudent.datatranferobject.PrerequisiteSubjectDetailDTO;
import mnstudent.datatranferobject.SubjectDTO;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author lee
 */
public class frmSubject extends javax.swing.JPanel {

    private SubjectBLL m_SubjectBLL;
    private KindOfSubjectBLL m_KindOfSubjectBLL;

    private int currentRow = 0;
    private ArrayList<KindOfSubjectDTO> arrKindOfSubjectDTO;
    private ArrayList<PrerequisiteSubjectDTO> arrPrerequisiteSubjectDTO, arrPrerequisiteSubjectChoosed;

    private ArrayList<MajorOfSubjectDTO> arrMajorOfSubjectDTO, arrMajorOfSubjectChoosed;
    private MajorOfSubjectDTO objSeletedAll;
    
    private DefaultTableModel m_Model;
    private DefaultTableModel m_ModelMajorOfSubject;
    private DefaultTableModel m_ModelPrerequisiteSubject;

    private JPopupMenu jpMenuJXTableSub;//Cac JXTable phụ
  

    /**
     * Creates new form frmFaculty
     */
    public frmSubject() {
        initComponents();
        initControls();
        prepare();
    }

    /**
     * Init Controls
     */
    private void initControls() {

        jxTxtSubjectID.setEditable(false);//luon luon false
        jxtabDetails.setEditable(false);
        jXTablePrerequisiteSubject.setEditable(false);

        //neu chua them moi thi EditTable = false
        if (!this.jxtabDetails.m_isAdd && !this.jxtabDetails.m_isUpdate) {

            jxTxtNameOfSubject.setEditable(false);
            jXCbMajorOfSubject.setEnabled(false);
            jXCbKindOfSubject.setEnabled(false);
            jXCbPrerequisiteSubject.setEnabled(false);
            jSpinnerNumberOfCredit.setEnabled(false);
            jxBtnSave.setEnabled(false);
            jxBtnCancel.setEnabled(false);

            jxBtnAdd.setEnabled(true);
            jxBtnUpdate.setEnabled(true);
            jxBtnDelete.setEnabled(true);

            jXTableMajorOfSubject.setEditable(false);
        } else {

            jxTxtNameOfSubject.setEditable(true);
            jXCbMajorOfSubject.setEnabled(true);
            jXCbKindOfSubject.setEnabled(true);
            jXCbPrerequisiteSubject.setEnabled(true);
            jSpinnerNumberOfCredit.setEnabled(true);
            jxBtnSave.setEnabled(true);
            jxBtnCancel.setEnabled(true);

            jxBtnAdd.setEnabled(false);
            jxBtnUpdate.setEnabled(false);
            jxBtnDelete.setEnabled(false);

            jXTableMajorOfSubject.setEditable(true);
        }
    }

    /**
     * Prepare
     */
    private void prepare() {

        //Set lai text cac button cua dialog
        UIManager.put("OptionPane.cancelButtonText", "Hủy");
        UIManager.put("OptionPane.noButtonText", "Không");
        UIManager.put("OptionPane.okButtonText", "Có");
        UIManager.put("OptionPane.yesButtonText", "Vâng");
        //
        this.m_SubjectBLL = new SubjectBLL();
        this.m_KindOfSubjectBLL = new KindOfSubjectBLL();
        this.arrPrerequisiteSubjectChoosed = new ArrayList<>();
        this.arrMajorOfSubjectChoosed = new ArrayList<>();

        m_Model = (DefaultTableModel) jxtabDetails.getModel();
        DataTable.addRowForSubject(m_SubjectBLL.getAllSubject(), m_KindOfSubjectBLL.getAllKindOfSubjectToArray(), m_Model);

        bindingDataToComboBoxs();
        bindingDataToComboBoxPrerequisiteSubject();
        bindingDataToComboBoxMajorOfSubject();

        // DataTable.addRow(m_SubjectBLL.getAllSubjectWithNameOfFaculty(), m_Model);
        //get selected item
        jxtabDetails.setDefaultRenderer(Object.class, new MyTableCellRender());
        jxtabDetails.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
            @Override
            public void valueChanged(ListSelectionEvent lse) {

                if (!(jxtabDetails.getSelectionModel().isSelectionEmpty())) {
                    //retrieving the selected row index
                    currentRow = jxtabDetails.getSelectedRow();
                    //if a single row is selected from the table, take each cell values into the controls
                    if (jxtabDetails.getRowSelectionAllowed() && jxtabDetails.getRowCount() > 0) {
                        if (jxtabDetails.m_isAdd || jxtabDetails.m_isUpdate) {
                            int rs = JOptionPane.showOptionDialog(null,
                                    "Vui lòng lưu thay đổi trước khi chuyển sang dòng khác!",
                                    "Cảnh báo",
                                    JOptionPane.YES_NO_OPTION,
                                    JOptionPane.QUESTION_MESSAGE,
                                    null,
                                    null,
                                    null);
                            if (rs == 0)//Yes
                            {
                                save();
                            } else {
                                cancelAction();
                            }
                        } else {
                            bindingDataToControls();
                            bindingDataToComboBoxPrerequisiteSubject();
                            bindingDataToComboBoxMajorOfSubject();
                        }
                    }
                }
            }
        });
        //neu co dl thi do mac dinh row dau tien
        if (jxtabDetails.getRowCount() > 0) {
            jxtabDetails.setRequestFocusEnabled(true);
            jxtabDetails.requestFocus();
            jxtabDetails.changeSelection(jxtabDetails.getRowCount() - 1, jxtabDetails.getRowCount() - 1, false, false);
        }
    }

    private void initJPopupMenu()
    {
        if(jpMenuJXTableSub == null){
            
            ActionListener menuListener = new ActionListener() {
                public void actionPerformed(ActionEvent event) {
                    if(jXTableMajorOfSubject.getRowCount()>0 && jXTablePrerequisiteSubject.getRowCount()>0)
                    {
                        ;
                    }
                }
            };
            
            jpMenuJXTableSub = new JPopupMenu();
            JMenuItem menuItemRemove = new JMenuItem("Xóa dòng hiện tại");
            menuItemRemove.addActionListener(menuListener);
            JMenuItem menuItemRemoveCurrentSeleted = new JMenuItem("Xóa các dòng vừa chọn");
            menuItemRemoveCurrentSeleted.addActionListener(menuListener);
            JMenuItem menuItemRemoveAll = new JMenuItem("Xóa tất cả");
            menuItemRemoveCurrentSeleted.addActionListener(menuListener);

            jpMenuJXTableSub.add(menuItemRemove);
            jpMenuJXTableSub.add(menuItemRemoveCurrentSeleted);
            jpMenuJXTableSub.add(menuItemRemoveAll);
            //thêm vào các JXTable
            jXTableMajorOfSubject.setComponentPopupMenu(jpMenuJXTableSub);
            jXTablePrerequisiteSubject.setComponentPopupMenu(jpMenuJXTableSub);
            
            
            
        }
        else
        {
            jpMenuJXTableSub.show();
        }

   }
    private void bindingDataToControls() {
        String strSubjectID = jxtabDetails.getValueAt(currentRow, 0).toString();
        String strNameOfSubject = jxtabDetails.getValueAt(currentRow, 1).toString();
        int iCredit = (jxtabDetails.getValueAt(currentRow, 2) == null || jxtabDetails.getValueAt(currentRow, 2).equals(""))
                ? 0 : Integer.parseInt(jxtabDetails.getValueAt(currentRow, 2).toString());

        jxTxtSubjectID.setText(strSubjectID);
        jxTxtNameOfSubject.setText(strNameOfSubject);
        jSpinnerNumberOfCredit.setValue(iCredit);

        //ComboBox LOAIMONHOC 
        if (!jxtabDetails.getValueAt(currentRow, 3).equals("")) {
            KindOfSubjectDTO objKindOfSubject = (KindOfSubjectDTO) jxtabDetails.getValueAt(currentRow, 3);
            jXCbKindOfSubject.setSelectedItem(objKindOfSubject);
        }

        if (!this.jxtabDetails.m_isAdd || !this.jxtabDetails.m_isUpdate) {
            if (!jxtabDetails.getValueAt(currentRow, 0).equals("")) {
                //ComboBox Môn học tiên quyết
                ArrayList<PrerequisiteSubjectDTO> arrPrerequisiteSubject = m_SubjectBLL.getListPrerequisiteSubjectOfSubject(jxTxtSubjectID.getText().trim());
                initJTableForPrerequisiteSubject(arrPrerequisiteSubject);

                //ComboBox Ngành của môn học
                ArrayList<MajorOfSubjectDTO> arrMajorOfSubject = m_SubjectBLL.getListMajorOfSubject(jxTxtSubjectID.getText().trim());
                initJTableForMajorOfSubject(arrMajorOfSubject);
            }
        }
    }

    private void initJTableForMajorOfSubject(ArrayList<MajorOfSubjectDTO> _arrMajorOfSubject) {
        m_ModelMajorOfSubject = (DefaultTableModel) jXTableMajorOfSubject.getModel();
        if (_arrMajorOfSubject.size() > 0) {
            m_ModelMajorOfSubject.fireTableDataChanged();
            m_ModelMajorOfSubject.fireTableStructureChanged();
            m_ModelMajorOfSubject.getDataVector().removeAllElements();

            for (MajorOfSubjectDTO obj : _arrMajorOfSubject) {
                Vector _row = new Vector();
                _row.addElement(obj.getMajorID());
                _row.addElement(obj.getNameOfMajor());

                if (obj.getOrderSemesterID() != null) {
                    for (OrderSemesterDTO obj1 : m_SubjectBLL.getAllOrderSemesterToArray()) {
                        if (obj.getOrderSemesterID().equals(obj1.getM_OrderSemesterID())) {
                            _row.addElement(obj1);
                            break;
                        }
                    }
                }
                m_ModelMajorOfSubject.addRow(_row);
            }
        } else {
            if (m_ModelMajorOfSubject.getRowCount() > 0) {
                int temp = m_ModelMajorOfSubject.getRowCount();
                for (int i = 0; i < temp; i++) {
                    m_ModelMajorOfSubject.removeRow(0);
                }
            }
        }
        jXTableMajorOfSubject.setDefaultRenderer(Object.class, new MyTableCellRender());
        Object[] values = m_SubjectBLL.getAllOrderSemesterToArray().toArray();
        TableColumn col = jXTableMajorOfSubject.getColumnModel().getColumn(2);
        MyComboBoxEditor editer = new MyComboBoxEditor(values);
        col.setCellEditor(editer);
        MyComboBoxRenderer render = new MyComboBoxRenderer(values);
        col.setCellRenderer(render);
        editer.addCellEditorListener(new CellEditorListener() {

            @Override
            public void editingStopped(ChangeEvent e) {
                //chỗ này là sự kiên khi click vào commobox
                DefaultCellEditor obj = (DefaultCellEditor) e.getSource();
                OrderSemesterDTO a = (OrderSemesterDTO) obj.getCellEditorValue();
                if (a != null && jXTableMajorOfSubject.getSelectedRow()!=-1) {
                    MajorOfSubjectDTO objTemp = arrMajorOfSubjectChoosed.get(jXTableMajorOfSubject.getSelectedRow());
                    arrMajorOfSubjectChoosed.remove(jXTableMajorOfSubject.getSelectedRow());
                    objTemp.setOrderSemesterID(a.getM_OrderSemesterID());
                    arrMajorOfSubjectChoosed.add(jXTableMajorOfSubject.getSelectedRow(), objTemp);
                }
            }

            @Override
            public void editingCanceled(ChangeEvent e) {
            }

        });

    }

    private void initJTableForPrerequisiteSubject(ArrayList<PrerequisiteSubjectDTO> _arrPrerequisiteSubject) {

        m_ModelPrerequisiteSubject = (DefaultTableModel) jXTablePrerequisiteSubject.getModel();
        if (_arrPrerequisiteSubject.size() > 0) {
            m_ModelPrerequisiteSubject.fireTableDataChanged();
            m_ModelPrerequisiteSubject.fireTableStructureChanged();
            m_ModelPrerequisiteSubject.getDataVector().removeAllElements();

            for (PrerequisiteSubjectDTO obj : _arrPrerequisiteSubject) {
                Vector _row = new Vector();
                _row.addElement(obj.getSubjectID());
                _row.addElement(obj.getNameOfSubject());
                m_ModelPrerequisiteSubject.addRow(_row);
            }
        } else {
            if (m_ModelPrerequisiteSubject.getRowCount() > 0) {
                int temp = m_ModelPrerequisiteSubject.getRowCount();
                for (int i = 0; i < temp; i++) {
                    m_ModelPrerequisiteSubject.removeRow(0);
                }
            }
        }
        jXTablePrerequisiteSubject.setDefaultRenderer(Object.class, new MyTableCellRender());

    }

    private void bindingDataToComboBoxs() {
        //comboBox LoaiMonHoc(KindOfSubject)
        arrKindOfSubjectDTO = new ArrayList<>();
        KindOfSubjectBLL _kindofsubjectBLL = new KindOfSubjectBLL();
        arrKindOfSubjectDTO = _kindofsubjectBLL.getAllKindOfSubjectToArray();
        DefaultComboBoxModel dfComboBoxModelKindOfSubject = new DefaultComboBoxModel(arrKindOfSubjectDTO.toArray());
        jXCbKindOfSubject.setModel(dfComboBoxModelKindOfSubject);

        if (jxtabDetails.getRowCount() == 0) {
            jXCbKindOfSubject.setSelectedIndex(-1);
        }
    }

    private void bindingDataToComboBoxPrerequisiteSubject() {
        //ComboBox Môn học tiên quyết
        if (this.jxtabDetails.m_isAdd || this.jxtabDetails.m_isUpdate)// bind du lieu len khi thuc hien them moi hoac cap nhat
        {
            if (jXCbPrerequisiteSubject.getModel().getSize() > 0) {
                jXCbPrerequisiteSubject.removeAll();
            }
            arrPrerequisiteSubjectDTO = new ArrayList<>();
            SubjectBLL arrPrerequisiteSubjectBLL = new SubjectBLL();
            arrPrerequisiteSubjectDTO = arrPrerequisiteSubjectBLL.getAllPrerequisiteSubjectToArray();
            DefaultComboBoxModel dfComboBoxModelObject = new DefaultComboBoxModel(arrPrerequisiteSubjectDTO.toArray());
            jXCbPrerequisiteSubject.setModel(dfComboBoxModelObject);
        } else//luc xem du lieu co san tren JTable
        {
            if (jXCbPrerequisiteSubject.getModel().getSize() > 0) {
                jXCbPrerequisiteSubject.removeAllItems();
            }
            if (jxtabDetails.getValueAt(currentRow, 4) != null) {
                String[] arrObject = {jxtabDetails.getValueAt(currentRow, 4).toString()};
                DefaultComboBoxModel dfComboBoxModelObject = new DefaultComboBoxModel(arrObject);
                jXCbPrerequisiteSubject.setModel(dfComboBoxModelObject);
            }
        }
    }

    private void bindingDataToComboBoxMajorOfSubject() {
        //ComboBox Ngành
        if (this.jxtabDetails.m_isAdd || this.jxtabDetails.m_isUpdate)// bind du lieu len khi thuc hien them moi hoac cap nhat
        {
            if (jXCbMajorOfSubject.getModel().getSize() > 0) {
                jXCbMajorOfSubject.removeAll();
            }
            arrMajorOfSubjectDTO = new ArrayList<>();
            SubjectBLL arrSubjectBLL = new SubjectBLL();
            arrMajorOfSubjectDTO = arrSubjectBLL.getAllMajorToArray();
            objSeletedAll = new MajorOfSubjectDTO("MHTatCa", "Chọn tất cả");
            arrMajorOfSubjectDTO.add(objSeletedAll);
            DefaultComboBoxModel dfComboBoxModelObject = new DefaultComboBoxModel(arrMajorOfSubjectDTO.toArray());
            jXCbMajorOfSubject.setModel(dfComboBoxModelObject);
        } else//luc xem du lieu co san tren JTable
        {
            if (jXCbMajorOfSubject.getModel().getSize() > 0) {
                jXCbMajorOfSubject.removeAllItems();
            }
            if (jxtabDetails.getValueAt(currentRow, 5) != null) {
                String[] arrObject = {jxtabDetails.getValueAt(currentRow, 5).toString()};
                DefaultComboBoxModel dfComboBoxModelObject = new DefaultComboBoxModel(arrObject);
                jXCbMajorOfSubject.setModel(dfComboBoxModelObject);
            }
        }
    }

    /**
     * Ham thuc hien viec cap nhat va update
     */
    private void save() {
        if (this.jxtabDetails.m_isAdd) {
            saveToDatabase();
            
        } else if (this.jxtabDetails.m_isUpdate) {
            updateToDatabase();
        }
    }

    private void updateToDatabase() {
        //Tien sau khi update tren bang sinh vien xong thi update tiep bang ct_doituong
        boolean m_isUpdate = false;
        if (checkData()) {
            SubjectDTO subjectObj = new SubjectDTO();

            subjectObj.setSubjectID(jxTxtSubjectID.getText());
            subjectObj.setNameOfSubject(jxTxtNameOfSubject.getText());
            subjectObj.setNumberOfCredit((int) jSpinnerNumberOfCredit.getValue());
            subjectObj.setKindOfSubjectID(((KindOfSubjectDTO) jXCbKindOfSubject.getSelectedItem()).getKindOfSubjectID());
            subjectObj.setM_ListPrerequisiteSubject(arrPrerequisiteSubjectChoosed);
            subjectObj.setListMajorOfSubject(arrMajorOfSubjectChoosed);

            //update
            if (m_SubjectBLL.updateSubjectToDatabase(subjectObj)) {
                //Tien hanh xoa trong CT_MONHOC
                if (m_SubjectBLL.deletePrerequisiteSubjectDetailFromDatabase(subjectObj.getSubjectID())
                        && m_SubjectBLL.deleteMajorOfSubjectDetailFromDatabase(subjectObj.getSubjectID())) {
                    //Insert lai vao CT_MONHOC
                    if (isSaveDetailPrerequisiteSubject(subjectObj)) {
                        //Insert lai vao CT_NGANH_MONHOC
                        if (isSaveDetailMajorOfSubject(subjectObj)) {
                            
                            JOptionPane.showOptionDialog(null,
                                    "Câp nhật thành công!",
                                    "Thông báo",
                                    JOptionPane.YES_OPTION,
                                    JOptionPane.QUESTION_MESSAGE,
                                    null,
                                    null,
                                    null);
                            //neu Cập nhật thanh cong
                            this.jxtabDetails.m_isUpdate = false;
                            initControls();
                            refreshDataInJTable();
                            arrPrerequisiteSubjectChoosed.clear();
                            arrMajorOfSubjectChoosed.clear();
                        } else {
                            JOptionPane.showMessageDialog(null, "Cập nhật thất bại. Vui lòng kiểm tra lại!", "Lỗi", JOptionPane.YES_OPTION);
                        }
                    }
                }
            } else {
                JOptionPane.showMessageDialog(null, "Cập nhật thất bại. Vui lòng kiểm tra lại!", "Lỗi", JOptionPane.YES_OPTION);
            }
        }
    }

    /**
     * Ham thuc hien insert MonHoc xuong database
     *
     * @return
     */
    private void saveToDatabase() {
        if (checkData()) {
            SubjectDTO subjectObj = new SubjectDTO();

            subjectObj.setSubjectID(jxTxtSubjectID.getText());
            subjectObj.setNameOfSubject(jxTxtNameOfSubject.getText());
            subjectObj.setNumberOfCredit((int) jSpinnerNumberOfCredit.getValue());
            subjectObj.setKindOfSubjectID(((KindOfSubjectDTO) jXCbKindOfSubject.getSelectedItem()).getKindOfSubjectID());
            subjectObj.setM_ListPrerequisiteSubject(arrPrerequisiteSubjectChoosed);

            if (m_SubjectBLL.insertSubjectToDatabase(subjectObj)) {
                subjectObj.setSubjectID(m_SubjectBLL.getIDSubject());
                if (isSaveDetailPrerequisiteSubject(subjectObj)) {
                     JOptionPane.showOptionDialog(null,
                        "Lưu xuống thành công!",
                        "Thông báo",
                        JOptionPane.YES_OPTION,
                        JOptionPane.QUESTION_MESSAGE,
                        null,
                        null,
                        null);
                //neu luu thanh cong
                this.jxtabDetails.m_isAdd = false;
                initControls();
                refreshDataInJTable();
                arrPrerequisiteSubjectChoosed.clear();
                arrMajorOfSubjectChoosed.clear();
                } else {
                    JOptionPane.showMessageDialog(null, "Lưu xuống thất bại. Vui lòng kiểm tra lại!", "Lỗi", JOptionPane.YES_OPTION);
                }
            }
        }
    }

    /**
     * Hàm lưu chi tiết mon hoc tien quyet xuống database
     *
     * @return
     */
    private boolean isSaveDetailPrerequisiteSubject(SubjectDTO subject) {
        boolean rs = false;
        if (subject.getM_ListPrerequisiteSubject().size() == 0) {
                rs = true;
        } else {
            ArrayList<PrerequisiteSubjectDetailDTO> arr = new ArrayList<PrerequisiteSubjectDetailDTO>();
            for (PrerequisiteSubjectDTO i : subject.getM_ListPrerequisiteSubject()) {
                arr.add(new PrerequisiteSubjectDetailDTO(subject.getSubjectID(), i.getSubjectID()));
            }
            if (m_SubjectBLL.insertArrayPrerequisiteSubjectDetail(arr)) {
                rs = true;
            }
        }
        return rs;
    }
    /**
     * Hàm này tao sửa lại chỗ check data: chỗ môn học tiên quyết, vì có môn có thể ko co môn học tiên quyết
     * @return 
     */
    private boolean checkData() {
        if (jxTxtSubjectID.getText().equals("")
                || jxTxtNameOfSubject.getText().equals("")
                || jSpinnerNumberOfCredit.getValue().equals("")
                || jXCbKindOfSubject.getSelectedIndex() == -1
                || arrMajorOfSubjectChoosed.isEmpty()) {
               
            JOptionPane.showOptionDialog(null,
                    "Dữ liệu không được bỏ trống. Vui lòng nhập lại!",
                    "Cảnh báo",
                    JOptionPane.YES_OPTION,
                    JOptionPane.WARNING_MESSAGE,
                    null,
                    null,
                    null);
            return false;
        } else {
            for (int i = 0; i < arrMajorOfSubjectChoosed.size(); i++) {
                if(arrMajorOfSubjectChoosed.get(i).getOrderSemesterID()==null){
                    JOptionPane.showOptionDialog(null,
                        "Dữ liệu không được bỏ trống. Vui lòng nhập lại!",
                        "Cảnh báo",
                        JOptionPane.YES_OPTION,
                        JOptionPane.WARNING_MESSAGE,
                        null,
                        null,
                        null);
                    return false;
                }
            }
            return true;
        }

    }

    private boolean isSaveDetailMajorOfSubject(SubjectDTO subjectObj) {
        boolean rs = false;
        if (subjectObj.getListMajorOfSubject().size() == 1) {
            if (jXTableMajorOfSubject.getModel().getValueAt(0, 2) == null) {
                //Chưa chọn thứ tự học kỳ
                JOptionPane.showMessageDialog(this, "Làm ơn chọn thứ tự học kỳ cho ngành môn học.");
                rs = false;
            } else {
                MajorOfSubjectDetailDTO subMajorOfSubjectObj = new MajorOfSubjectDetailDTO(subjectObj.getListMajorOfSubject().get(0).getMajorID().trim(), subjectObj.getSubjectID(), ((OrderSemesterDTO) jXTableMajorOfSubject.getModel().getValueAt(0, 2)).getM_OrderSemesterID());
                if (m_SubjectBLL.insertMajorOfSubjectDetail(subMajorOfSubjectObj)) {
                    rs = true;
                }
            }
        } else {
            ArrayList<MajorOfSubjectDetailDTO> arr = new ArrayList<MajorOfSubjectDetailDTO>();
            int icount = 0;
            for (MajorOfSubjectDTO i : subjectObj.getListMajorOfSubject()) {
                OrderSemesterDTO ordersemestertemp = (OrderSemesterDTO) jXTableMajorOfSubject.getValueAt(icount, 2);
                if (ordersemestertemp == null) {
                    JOptionPane.showMessageDialog(this, "Làm ơn chọn thứ tự học kỳ cho ngành môn học.");
                    return false;
                } else {
                    arr.add(new MajorOfSubjectDetailDTO(i.getMajorID(), subjectObj.getSubjectID(), ordersemestertemp.getM_OrderSemesterID()));
                    icount++;
                }
            }
            if (m_SubjectBLL.insertArrayMajorOfSubjectDetail(arr)) {
                rs = true;
            }
        }
        return rs;
    }

    private void cancelAction() {
        if (this.jxtabDetails.m_isAdd) {
            ((DefaultTableModel) jxtabDetails.getModel()).removeRow(jxtabDetails.getRowCount() - 1);
            this.jxtabDetails.m_isAdd = false;
            initControls();
            jxTxtSubjectID.setText("");
            jxTxtNameOfSubject.setText("");
            jxtabDetails.changeSelection(jxtabDetails.getRowCount() - 1, jxtabDetails.getRowCount() - 1, false, false);

        } else {
            this.jxtabDetails.m_isUpdate = false;
            initControls();

        }
        refreshDataInJTable();
        arrPrerequisiteSubjectChoosed.clear();
        arrMajorOfSubjectChoosed.clear();
        //hủy các Context menu trên 2 JXTable
        if(jpMenuJXTableSub != null )
        {
            jpMenuJXTableSub.hide();
       }
    }

    /**
     * Ham xoa 1 MONHOC dc chon
     *
     * @param rowSelected
     * @return
     */
    private boolean isDelete(int rowSelected) {
        boolean m_isDelete = false;

        String id = this.jxtabDetails.getValueAt(rowSelected, 0).toString();
        String name = this.jxtabDetails.getValueAt(rowSelected, 1).toString();
        int numberofcredit = Integer.parseInt(this.jxtabDetails.getValueAt(rowSelected, 2).toString());
        String id_kindofsubject = ((KindOfSubjectDTO) this.jxtabDetails.getValueAt(rowSelected, 3)).getKindOfSubjectID();

        SubjectDTO subjectObj = new SubjectDTO(id, name, name, numberofcredit);
        if (m_SubjectBLL.deleteSubjectFromDatabase(subjectObj)) {
            m_Model.removeRow(rowSelected);
            m_isDelete = true;
        }

        return m_isDelete;
    }

    private boolean isDeleteMoreSubject() {
        boolean m_isDelete = true;
        int[] arrRowSelected = this.jxtabDetails.getSelectedRows();
        for (int i = arrRowSelected.length - 1; i >= 0; i--) {
            if (!isDelete(arrRowSelected[i])) {
                JOptionPane.showMessageDialog(null,
                        "Xóa thất bại môn học: " + jxtabDetails.getValueAt(arrRowSelected[i], 1),
                        "Lỗi",
                        JOptionPane.YES_OPTION);
                m_isDelete = false;
            }
        }
        return m_isDelete;
    }

    /**
     * Refresh Data Table
     */
    private void refreshDataInJTable() {
        
        m_Model.fireTableDataChanged();
        m_Model.fireTableStructureChanged();
        m_Model.getDataVector().removeAllElements();
        DataTable.addRowForSubject(m_SubjectBLL.getAllSubject(), arrKindOfSubjectDTO, m_Model);
        if (jxtabDetails.getRowCount() > 0) {
            jxtabDetails.setRequestFocusEnabled(true);
            jxtabDetails.requestFocus();
            jxtabDetails.changeSelection(jxtabDetails.getRowCount() - 1, jxtabDetails.getRowCount() - 1, false, false);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        jxpanDetails = new org.jdesktop.swingx.JXPanel();
        jpanTableDetails = new javax.swing.JPanel();
        jpanContent = new javax.swing.JPanel();
        jxpanFindNavibar = new org.jdesktop.swingx.JXPanel();
        jpanChose = new javax.swing.JPanel();
        jChkSearchWithMajorID = new javax.swing.JCheckBox();
        jChkSearchWithMajorName = new javax.swing.JCheckBox();
        jChkSearchFast = new javax.swing.JCheckBox();
        jChkSearchWithFacultyName = new javax.swing.JCheckBox();
        jChkSearchWithMajorName1 = new javax.swing.JCheckBox();
        jChkSearchWithMajorName2 = new javax.swing.JCheckBox();
        jxbtnFindVisible = new org.jdesktop.swingx.JXButton();
        jxSearchFaculty = new org.jdesktop.swingx.JXSearchField();
        jXLabel1 = new org.jdesktop.swingx.JXLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jxtabDetails = new mnstudent.global.MyTable();
        jpanFuntionalDetails = new javax.swing.JPanel();
        jxBtnAdd = new org.jdesktop.swingx.JXButton();
        jxBtnUpdate = new org.jdesktop.swingx.JXButton();
        jxBtnDelete = new org.jdesktop.swingx.JXButton();
        jxBtnSave = new org.jdesktop.swingx.JXButton();
        jxBtnCancel = new org.jdesktop.swingx.JXButton();
        jxpanHeader = new org.jdesktop.swingx.JXPanel();
        jxpanTitleHeader = new org.jdesktop.swingx.JXPanel();
        jXLabel5 = new org.jdesktop.swingx.JXLabel();
        jxpanInfoHeader = new org.jdesktop.swingx.JXPanel();
        jxpanInfo = new org.jdesktop.swingx.JXPanel();
        jxLabFacultyID = new org.jdesktop.swingx.JXLabel();
        jxTxtSubjectID = new org.jdesktop.swingx.JXTextField();
        jxLabNameOfFaculty = new org.jdesktop.swingx.JXLabel();
        jxTxtNameOfSubject = new org.jdesktop.swingx.JXTextField();
        jxLabNameOfFaculty1 = new org.jdesktop.swingx.JXLabel();
        jXCbMajorOfSubject = new org.jdesktop.swingx.JXComboBox();
        jxLabFacultyID1 = new org.jdesktop.swingx.JXLabel();
        jXCbKindOfSubject = new org.jdesktop.swingx.JXComboBox();
        jxLabNameOfFaculty2 = new org.jdesktop.swingx.JXLabel();
        jXCbPrerequisiteSubject = new org.jdesktop.swingx.JXComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        jXTableMajorOfSubject = new mnstudent.global.MyTable();
        jScrollPane3 = new javax.swing.JScrollPane();
        jXTablePrerequisiteSubject = new mnstudent.global.MyTable();
        lblNumberOfCredit = new javax.swing.JLabel();
        jSpinnerNumberOfCredit = new javax.swing.JSpinner();
        jXCbKindOfSubject1 = new org.jdesktop.swingx.JXComboBox();
        jxLabFacultyID2 = new org.jdesktop.swingx.JXLabel();

        setLayout(new java.awt.BorderLayout());

        jxpanDetails.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jxpanDetails.setLayout(new java.awt.BorderLayout());

        jpanTableDetails.setLayout(new java.awt.BorderLayout());

        jpanContent.setLayout(new java.awt.BorderLayout());

        jxpanFindNavibar.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jxpanFindNavibar.setPreferredSize(new java.awt.Dimension(914, 30));

        jpanChose.setBorder(javax.swing.BorderFactory.createTitledBorder("Chọn nội dung tìm kiếm"));

        jChkSearchWithMajorID.setText("Tìm theo mã môn");

        jChkSearchWithMajorName.setText("Tìm theo ngành");

        jChkSearchFast.setText("Tìm kiếm nhanh");

        jChkSearchWithFacultyName.setText("Tìm theo tên môn");

        jChkSearchWithMajorName1.setText("Tìm theo loại môn học");

        jChkSearchWithMajorName2.setText("Tìm theo môn tiên quyết");

        javax.swing.GroupLayout jpanChoseLayout = new javax.swing.GroupLayout(jpanChose);
        jpanChose.setLayout(jpanChoseLayout);
        jpanChoseLayout.setHorizontalGroup(
            jpanChoseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanChoseLayout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(jChkSearchWithMajorID)
                .addGap(30, 30, 30)
                .addComponent(jChkSearchWithFacultyName)
                .addGap(30, 30, 30)
                .addComponent(jChkSearchWithMajorName)
                .addGap(30, 30, 30)
                .addComponent(jChkSearchWithMajorName1)
                .addGap(30, 30, 30)
                .addComponent(jChkSearchWithMajorName2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 169, Short.MAX_VALUE)
                .addComponent(jChkSearchFast)
                .addContainerGap(173, Short.MAX_VALUE))
        );
        jpanChoseLayout.setVerticalGroup(
            jpanChoseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpanChoseLayout.createSequentialGroup()
                .addGroup(jpanChoseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jChkSearchWithMajorID)
                    .addComponent(jChkSearchFast)
                    .addComponent(jChkSearchWithFacultyName)
                    .addComponent(jChkSearchWithMajorName)
                    .addComponent(jChkSearchWithMajorName1)
                    .addComponent(jChkSearchWithMajorName2))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jxbtnFindVisible.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
        jxbtnFindVisible.setText("Tùy chọn");
        jxbtnFindVisible.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jxbtnFindVisibleActionPerformed(evt);
            }
        });

        jXLabel1.setText("Tìm kiếm:");

        javax.swing.GroupLayout jxpanFindNavibarLayout = new javax.swing.GroupLayout(jxpanFindNavibar);
        jxpanFindNavibar.setLayout(jxpanFindNavibarLayout);
        jxpanFindNavibarLayout.setHorizontalGroup(
            jxpanFindNavibarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jxpanFindNavibarLayout.createSequentialGroup()
                .addComponent(jxbtnFindVisible, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jXLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jxSearchFaculty, javax.swing.GroupLayout.PREFERRED_SIZE, 219, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(jpanChose, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jxpanFindNavibarLayout.setVerticalGroup(
            jxpanFindNavibarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jxpanFindNavibarLayout.createSequentialGroup()
                .addGroup(jxpanFindNavibarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jxbtnFindVisible, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jxSearchFaculty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jXLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpanChose, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jpanContent.add(jxpanFindNavibar, java.awt.BorderLayout.NORTH);

        jxtabDetails.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Mã môn học", "Tên môn học", "Số tiết", "Loại môn học", "Môn học tiên quyết", "Ngành"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Object.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, true, true, true, true, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(jxtabDetails);

        jpanContent.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jpanTableDetails.add(jpanContent, java.awt.BorderLayout.CENTER);

        jpanFuntionalDetails.setLayout(new java.awt.GridBagLayout());

        jxBtnAdd.setText("Thêm mới");
        jxBtnAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jxBtnAddActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 20;
        gridBagConstraints.ipady = 6;
        gridBagConstraints.insets = new java.awt.Insets(8, 10, 6, 9);
        jpanFuntionalDetails.add(jxBtnAdd, gridBagConstraints);

        jxBtnUpdate.setText("Sửa đổi");
        jxBtnUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jxBtnUpdateActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 20;
        gridBagConstraints.ipady = 6;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTH;
        gridBagConstraints.insets = new java.awt.Insets(8, 10, 6, 8);
        jpanFuntionalDetails.add(jxBtnUpdate, gridBagConstraints);

        jxBtnDelete.setText("Xóa bỏ");
        jxBtnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jxBtnDeleteActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 20;
        gridBagConstraints.ipady = 6;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 4, 8);
        jpanFuntionalDetails.add(jxBtnDelete, gridBagConstraints);

        jxBtnSave.setText("Lưu xuống");
        jxBtnSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jxBtnSaveActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 20;
        gridBagConstraints.ipady = 6;
        gridBagConstraints.insets = new java.awt.Insets(11, 9, 7, 8);
        jpanFuntionalDetails.add(jxBtnSave, gridBagConstraints);

        jxBtnCancel.setText("Hủy bỏ");
        jxBtnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jxBtnCancelActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 5;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.ipadx = 20;
        gridBagConstraints.ipady = 6;
        gridBagConstraints.insets = new java.awt.Insets(12, 9, 8, 9);
        jpanFuntionalDetails.add(jxBtnCancel, gridBagConstraints);

        jpanTableDetails.add(jpanFuntionalDetails, java.awt.BorderLayout.EAST);

        jxpanDetails.add(jpanTableDetails, java.awt.BorderLayout.CENTER);

        add(jxpanDetails, java.awt.BorderLayout.CENTER);

        jxpanHeader.setLayout(new java.awt.BorderLayout());

        jxpanTitleHeader.setBorder(new org.jdesktop.swingx.border.DropShadowBorder());

        jXLabel5.setForeground(new java.awt.Color(0, 102, 255));
        jXLabel5.setText("MÔN HỌC");
        jXLabel5.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
        jxpanTitleHeader.add(jXLabel5);

        jxpanHeader.add(jxpanTitleHeader, java.awt.BorderLayout.PAGE_START);

        jxpanInfoHeader.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jxpanInfoHeader.setLayout(new java.awt.BorderLayout());

        jxpanInfo.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "THÔNG TIN", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP));

        jxLabFacultyID.setText("Mã môn học");

        jxTxtSubjectID.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                jxTxtSubjectIDCaretUpdate(evt);
            }
        });

        jxLabNameOfFaculty.setText("Tên môn học");

        jxTxtNameOfSubject.addCaretListener(new javax.swing.event.CaretListener() {
            public void caretUpdate(javax.swing.event.CaretEvent evt) {
                jxTxtNameOfSubjectCaretUpdate(evt);
            }
        });

        jxLabNameOfFaculty1.setText("Danh sách ngành của môn học");

        jXCbMajorOfSubject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXCbMajorOfSubjectActionPerformed(evt);
            }
        });

        jxLabFacultyID1.setText("Loại môn học");

        jXCbKindOfSubject.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jXCbKindOfSubjectItemStateChanged(evt);
            }
        });

        jxLabNameOfFaculty2.setText("Danh sách môn học tiên quyết");

        jXCbPrerequisiteSubject.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jXCbPrerequisiteSubjectActionPerformed(evt);
            }
        });

        jXTableMajorOfSubject.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Mã ngành", "Tên ngành", "Học kỳ thứ"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, true, true
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(jXTableMajorOfSubject);

        jXTablePrerequisiteSubject.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Mã môn học", "Tên môn"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane3.setViewportView(jXTablePrerequisiteSubject);

        lblNumberOfCredit.setText("Số tiết");

        jSpinnerNumberOfCredit.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jSpinnerNumberOfCreditStateChanged(evt);
            }
        });

        jXCbKindOfSubject1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jXCbKindOfSubject1ItemStateChanged(evt);
            }
        });

        jxLabFacultyID2.setText("Thuộc môn lý thuyết");

        javax.swing.GroupLayout jxpanInfoLayout = new javax.swing.GroupLayout(jxpanInfo);
        jxpanInfo.setLayout(jxpanInfoLayout);
        jxpanInfoLayout.setHorizontalGroup(
            jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jxpanInfoLayout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jxpanInfoLayout.createSequentialGroup()
                        .addComponent(jxLabFacultyID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jxTxtSubjectID, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jxLabNameOfFaculty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jxTxtNameOfSubject, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jxpanInfoLayout.createSequentialGroup()
                        .addComponent(jxLabNameOfFaculty1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                        .addComponent(jXCbMajorOfSubject, javax.swing.GroupLayout.PREFERRED_SIZE, 352, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(55, 55, 55)
                .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jxpanInfoLayout.createSequentialGroup()
                        .addComponent(jxLabFacultyID1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jXCbKindOfSubject, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jxpanInfoLayout.createSequentialGroup()
                        .addComponent(jxLabNameOfFaculty2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jXCbPrerequisiteSubject, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(50, 50, 50)
                .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jxLabFacultyID2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblNumberOfCredit))
                .addGap(18, 18, 18)
                .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSpinnerNumberOfCredit, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jXCbKindOfSubject1, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );
        jxpanInfoLayout.setVerticalGroup(
            jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jxpanInfoLayout.createSequentialGroup()
                .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jxpanInfoLayout.createSequentialGroup()
                        .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jxLabFacultyID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jxTxtSubjectID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jxLabNameOfFaculty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jxTxtNameOfSubject, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jxLabFacultyID1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jxLabNameOfFaculty1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jXCbMajorOfSubject, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                    .addGroup(jxpanInfoLayout.createSequentialGroup()
                        .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jxpanInfoLayout.createSequentialGroup()
                                .addComponent(jXCbKindOfSubject, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jxLabNameOfFaculty2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jXCbPrerequisiteSubject, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jxpanInfoLayout.createSequentialGroup()
                                .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jSpinnerNumberOfCredit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(lblNumberOfCredit, javax.swing.GroupLayout.Alignment.TRAILING))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jxpanInfoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jxLabFacultyID2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jXCbKindOfSubject1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)))
                .addGap(0, 0, 0))
        );

        jxpanInfoHeader.add(jxpanInfo, java.awt.BorderLayout.CENTER);

        jxpanHeader.add(jxpanInfoHeader, java.awt.BorderLayout.CENTER);

        add(jxpanHeader, java.awt.BorderLayout.NORTH);
    }// </editor-fold>//GEN-END:initComponents

    private void jxbtnFindVisibleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jxbtnFindVisibleActionPerformed
        if (jxbtnFindVisible.getText().equals("Đóng")) {
            jxbtnFindVisible.setPreferredSize(new Dimension(110, 25));
            jxbtnFindVisible.setText("Tùy chọn");
            jxbtnFindVisible.revalidate();
            jxpanFindNavibar.setPreferredSize(new Dimension(30, 30));
            jxpanFindNavibar.revalidate();
        } else {
            jxbtnFindVisible.setPreferredSize(new Dimension(20, 25));
            jxbtnFindVisible.setText("Đóng");
            jxbtnFindVisible.revalidate();
            jxpanFindNavibar.setPreferredSize(new Dimension(30, 105));
            jxpanFindNavibar.revalidate();
        }
    }//GEN-LAST:event_jxbtnFindVisibleActionPerformed

    private void jxBtnAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jxBtnAddActionPerformed
        for (int i = 0; i < jxtabDetails.getColumnCount(); i++) {
            if (jxtabDetails.getValueAt(jxtabDetails.getRowCount() - 1, i).equals("")) {
                return;
            }
        }
        Vector newRow = new Vector(jxtabDetails.getColumnCount());
        for (int i = 0; i < jxtabDetails.getColumnCount(); i++) {
            newRow.addElement("");
        }
        ((DefaultTableModel) jxtabDetails.getModel()).addRow(newRow);
        jxtabDetails.setRowSelectionInterval(jxtabDetails.getRowCount() - 1, jxtabDetails.getRowCount() - 1);
        //jxtabDetails.setEnabled(false);
        //jxtabDetails.setRowSelectionAllowed(false);
        if (!this.jxtabDetails.m_isAdd) {
            this.jxtabDetails.m_isAdd = true;
            initControls();
            this.jxtabDetails.m_rowIndex = jxtabDetails.getRowCount() - 1;
            
            jxTxtSubjectID.setText("MH0000***");
            jxTxtNameOfSubject.requestFocus();
            jXCbKindOfSubject.setSelectedItem(null);

            //xoa sach du lieu tren JTable ds Môn học tiên quyết
            DefaultTableModel _modelPrerequisiteSubject = (DefaultTableModel) this.jXTablePrerequisiteSubject.getModel();
            for (int i = _modelPrerequisiteSubject.getRowCount() - 1; i >= 0; i--) {
                _modelPrerequisiteSubject.removeRow(i);
            }
            bindingDataToComboBoxPrerequisiteSubject();

            //xoa sach du lieu tren JTable ds Ngành môn học
            DefaultTableModel _modelMajorOfSubject = (DefaultTableModel) this.jXTableMajorOfSubject.getModel();
            for (int i = _modelMajorOfSubject.getRowCount() - 1; i >= 0; i--) {
                _modelMajorOfSubject.removeRow(i);
            }
            bindingDataToComboBoxMajorOfSubject();

            jXCbMajorOfSubject.setSelectedItem(null);
            jXCbPrerequisiteSubject.setSelectedItem(null);
            
            //thêm Context menu vao 2 Jtable
             initJPopupMenu();
        }
    }//GEN-LAST:event_jxBtnAddActionPerformed

    private void jxTxtSubjectIDCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jxTxtSubjectIDCaretUpdate
        if (this.jxtabDetails.m_isAdd) {
            jxtabDetails.getModel().setValueAt(jxTxtSubjectID.getText(), jxtabDetails.getRowCount() - 1, 0);
        } else if (this.jxtabDetails.m_isUpdate) {
            jxtabDetails.getModel().setValueAt(jxTxtSubjectID.getText(), jxtabDetails.getSelectedRow(), 0);
        }
    }//GEN-LAST:event_jxTxtSubjectIDCaretUpdate

    private void jxTxtNameOfSubjectCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jxTxtNameOfSubjectCaretUpdate
        if (this.jxtabDetails.m_isAdd) {
            jxtabDetails.getModel().setValueAt(jxTxtNameOfSubject.getText(), jxtabDetails.getRowCount() - 1, 1);
        } else if (this.jxtabDetails.m_isUpdate) {
            jxtabDetails.getModel().setValueAt(jxTxtNameOfSubject.getText(), jxtabDetails.getSelectedRow(), 1);
        }
    }//GEN-LAST:event_jxTxtNameOfSubjectCaretUpdate

    private void jXCbKindOfSubjectItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jXCbKindOfSubjectItemStateChanged
        if(jXCbKindOfSubject.getSelectedItem() != null){
            KindOfSubjectDTO obj = (KindOfSubjectDTO) evt.getItem();
            if (this.jxtabDetails.m_isAdd || this.jxtabDetails.m_isUpdate) {
                jxtabDetails.getModel().setValueAt(obj, currentRow, 3);
            }
        }
    }//GEN-LAST:event_jXCbKindOfSubjectItemStateChanged

    private void jxBtnSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jxBtnSaveActionPerformed
        save();
    }//GEN-LAST:event_jxBtnSaveActionPerformed

    private void jxBtnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jxBtnUpdateActionPerformed
        this.jxtabDetails.m_isUpdate = true;
        bindingDataToComboBoxMajorOfSubject();
        bindingDataToComboBoxPrerequisiteSubject();
        initControls();
        jxTxtNameOfSubject.requestFocus();
      
        for (int i = 0; i < jXTablePrerequisiteSubject.getRowCount(); i++) {
            for (PrerequisiteSubjectDTO obj : arrPrerequisiteSubjectDTO) {
                if (obj.getSubjectID().equals(jXTablePrerequisiteSubject.getValueAt(i, 0).toString())) {
                    arrPrerequisiteSubjectChoosed.add(obj);
                }
            }
        }

        for (int i = 0; i < jXTableMajorOfSubject.getRowCount(); i++) {
            for (MajorOfSubjectDTO obj : arrMajorOfSubjectDTO) {
                if (obj.getMajorID().equals(jXTableMajorOfSubject.getValueAt(i, 0).toString())) {
                    OrderSemesterDTO ordersemester = (OrderSemesterDTO) jXTableMajorOfSubject.getValueAt(i, 2);
                    obj.setOrderSemesterID(ordersemester.getM_OrderSemesterID());
                    arrMajorOfSubjectChoosed.add(obj);
                }
            }
        }

        //xoa sach du lieu tren JTable
        DefaultTableModel _modelPrerequisiteSubject = (DefaultTableModel) this.jXTablePrerequisiteSubject.getModel();
        for (int i = _modelPrerequisiteSubject.getRowCount() - 1; i >= 0; i--) {
            _modelPrerequisiteSubject.removeRow(i);
        }

        //xoa sach du lieu tren JTable
        DefaultTableModel _modelMajorOfSubject = (DefaultTableModel) this.jXTableMajorOfSubject.getModel();
        for (int i = _modelMajorOfSubject.getRowCount() - 1; i >= 0; i--) {
            _modelMajorOfSubject.removeRow(i);
        }

        initJTableForPrerequisiteSubject(arrPrerequisiteSubjectChoosed);
        initJTableForMajorOfSubject(arrMajorOfSubjectChoosed);
        if(arrPrerequisiteSubjectChoosed.size()==0)
            jXCbPrerequisiteSubject.setSelectedItem(null);
        
        //thêm Context menu vao 2 Jtable
        initJPopupMenu();
    }//GEN-LAST:event_jxBtnUpdateActionPerformed

    private void jxBtnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jxBtnCancelActionPerformed
        cancelAction();
    }//GEN-LAST:event_jxBtnCancelActionPerformed

    private void jSpinnerNumberOfCreditStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinnerNumberOfCreditStateChanged
        if (jxtabDetails.m_isAdd || jxtabDetails.m_isUpdate) {
            String num = jSpinnerNumberOfCredit.getValue().toString();
            if (Integer.parseInt(num) < 0) {
                JOptionPane.showMessageDialog(this, "Số tiết lớn hơn 0.");
                jSpinnerNumberOfCredit.setValue(0);
                jxtabDetails.getModel().setValueAt(0, jxtabDetails.getSelectedRow(), 2);
            } else {
                jxtabDetails.getModel().setValueAt(num, jxtabDetails.getSelectedRow(), 2);
            }
        }
    }//GEN-LAST:event_jSpinnerNumberOfCreditStateChanged

    private void jXCbPrerequisiteSubjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXCbPrerequisiteSubjectActionPerformed
        if ((jxtabDetails.m_isAdd || jxtabDetails.m_isUpdate)&&jXCbPrerequisiteSubject.getSelectedItem() != null) {
            PrerequisiteSubjectDTO obj = (PrerequisiteSubjectDTO) jXCbPrerequisiteSubject.getSelectedItem();
            if (obj != null) {
                if (!arrPrerequisiteSubjectChoosed.contains(obj)) {
                    arrPrerequisiteSubjectChoosed.add(obj);
                } else {
                    arrPrerequisiteSubjectChoosed.remove(obj);
                }

                initJTableForPrerequisiteSubject(arrPrerequisiteSubjectChoosed);
                jxtabDetails.getModel().setValueAt(Standard.getToStringOfArrayPrerequisiteSubject(arrPrerequisiteSubjectChoosed), jxtabDetails.getSelectedRow(), 4);
            }
        }
    }//GEN-LAST:event_jXCbPrerequisiteSubjectActionPerformed

    private void jxBtnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jxBtnDeleteActionPerformed
        int rs = JOptionPane.showOptionDialog(null,
                "Bạn có muốn xóa không!",
                "Câu hỏi",
                JOptionPane.YES_NO_OPTION,
                JOptionPane.QUESTION_MESSAGE,
                null,
                null,
                null);
        if (rs == 0) {
            if (isDeleteMoreSubject()) {
                JOptionPane.showOptionDialog(null,
                        "Xóa thành công!",
                        "Thông báo",
                        JOptionPane.YES_OPTION,
                        JOptionPane.INFORMATION_MESSAGE,
                        null,
                        null,
                        null);
                //neu luu thanh cong
                this.jxtabDetails.m_isAdd = false;
                initControls();
                refreshDataInJTable();
            } else {
                JOptionPane.showMessageDialog(null, "Xóa thất bại. Vui lòng kiểm tra lại!", "Lỗi", JOptionPane.YES_OPTION);
            }
        }
    }//GEN-LAST:event_jxBtnDeleteActionPerformed

    private void jXCbMajorOfSubjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jXCbMajorOfSubjectActionPerformed
        if ((jxtabDetails.m_isAdd || jxtabDetails.m_isUpdate) &&jXCbMajorOfSubject.getSelectedItem() != null) {
            MajorOfSubjectDTO obj = (MajorOfSubjectDTO) jXCbMajorOfSubject.getSelectedItem();
            if (obj != null) {
                if(!obj.getMajorID().equals(objSeletedAll.getMajorID())){
                    if (!arrMajorOfSubjectChoosed.contains(obj)) {
                        arrMajorOfSubjectChoosed.add(obj);
                    } else {
                        arrMajorOfSubjectChoosed.remove(obj);
                    }
                }
                else
                {
                    arrMajorOfSubjectChoosed.clear();
                    arrMajorOfSubjectChoosed.addAll(arrMajorOfSubjectDTO);
                    arrMajorOfSubjectChoosed.remove(objSeletedAll);//loai bo thang chon tat ca ra khoi list
                }
                initJTableForMajorOfSubject(arrMajorOfSubjectChoosed);
                jxtabDetails.getModel().setValueAt(Standard.getToStringOfArrayMajorOfSubject(arrMajorOfSubjectChoosed), jxtabDetails.getSelectedRow(), 5);
            }
        }
    }//GEN-LAST:event_jXCbMajorOfSubjectActionPerformed

    private void jXCbKindOfSubject1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jXCbKindOfSubject1ItemStateChanged
        // TODO add your handling code here:
    }//GEN-LAST:event_jXCbKindOfSubject1ItemStateChanged


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox jChkSearchFast;
    private javax.swing.JCheckBox jChkSearchWithFacultyName;
    private javax.swing.JCheckBox jChkSearchWithMajorID;
    private javax.swing.JCheckBox jChkSearchWithMajorName;
    private javax.swing.JCheckBox jChkSearchWithMajorName1;
    private javax.swing.JCheckBox jChkSearchWithMajorName2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSpinner jSpinnerNumberOfCredit;
    private org.jdesktop.swingx.JXComboBox jXCbKindOfSubject;
    private org.jdesktop.swingx.JXComboBox jXCbKindOfSubject1;
    private org.jdesktop.swingx.JXComboBox jXCbMajorOfSubject;
    private org.jdesktop.swingx.JXComboBox jXCbPrerequisiteSubject;
    private org.jdesktop.swingx.JXLabel jXLabel1;
    private org.jdesktop.swingx.JXLabel jXLabel5;
    private org.jdesktop.swingx.JXTable jXTableMajorOfSubject;
    private org.jdesktop.swingx.JXTable jXTablePrerequisiteSubject;
    private javax.swing.JPanel jpanChose;
    private javax.swing.JPanel jpanContent;
    private javax.swing.JPanel jpanFuntionalDetails;
    private javax.swing.JPanel jpanTableDetails;
    private org.jdesktop.swingx.JXButton jxBtnAdd;
    private org.jdesktop.swingx.JXButton jxBtnCancel;
    private org.jdesktop.swingx.JXButton jxBtnDelete;
    private org.jdesktop.swingx.JXButton jxBtnSave;
    private org.jdesktop.swingx.JXButton jxBtnUpdate;
    private org.jdesktop.swingx.JXLabel jxLabFacultyID;
    private org.jdesktop.swingx.JXLabel jxLabFacultyID1;
    private org.jdesktop.swingx.JXLabel jxLabFacultyID2;
    private org.jdesktop.swingx.JXLabel jxLabNameOfFaculty;
    private org.jdesktop.swingx.JXLabel jxLabNameOfFaculty1;
    private org.jdesktop.swingx.JXLabel jxLabNameOfFaculty2;
    private org.jdesktop.swingx.JXSearchField jxSearchFaculty;
    private org.jdesktop.swingx.JXTextField jxTxtNameOfSubject;
    private org.jdesktop.swingx.JXTextField jxTxtSubjectID;
    private org.jdesktop.swingx.JXButton jxbtnFindVisible;
    private org.jdesktop.swingx.JXPanel jxpanDetails;
    private org.jdesktop.swingx.JXPanel jxpanFindNavibar;
    private org.jdesktop.swingx.JXPanel jxpanHeader;
    private org.jdesktop.swingx.JXPanel jxpanInfo;
    private org.jdesktop.swingx.JXPanel jxpanInfoHeader;
    private org.jdesktop.swingx.JXPanel jxpanTitleHeader;
    private mnstudent.global.MyTable jxtabDetails;
    private javax.swing.JLabel lblNumberOfCredit;
    // End of variables declaration//GEN-END:variables
}
